package procsim;

import java.awt.*;

public class GMemory extends Memory implements GraphicalElement {

    private int width = 150;
    private int height = 150;
    private int x, y;

    public GMemory(int now) {
        super(now);
    }

    public GMemory(int now, int nob) {
        super(now, nob);
    }

    @Override
    public void setCoords(int x, int y){
        this.x = x;
        this.y = y;
    }

    @Override
    public int getWidth() {
        return width;
    }

    @Override
    public int getHeight() {
        return height;
    }

    @Override
    public void setSize(int width, int height) {
        this.width = width;
        this.height = height;
    }

    @Override
    public void drawIt(Graphics2D g, int x, int y) {
        Util.saveGraphics(g);
        g.setColor(Color.BLACK);
        g.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12));
        g.drawRect(x+1, y+1, width-2, height-2);
        g.drawString("A", x+4, y+height/2+5);
        g.drawString("WR", x+4, y+height/2-30);
        g.drawString("RD", x+4, y+height/2+40);
        g.drawString("DIN", x+width/2-10, y+15);
        g.drawString("DOUT", x+width/2-15, y+height-5);
        g.setFont(new Font(Font.MONOSPACED, Font.BOLD, 16));
        g.drawString("MEM", x+width/2-15, y+height/2+5);
        Util.restoreGraphics(g);
    }

    @Override
    public void drawIt(Graphics2D g) {
        drawIt(g, x, y);
    }
}
